using System;
using UnityEngine;

namespace Flaschengeist.Views 
{
	public class MenuView : BaseView
	{				
		private const int boxWidth = 350;	
		private const int boxHeight = 260;
		private Texture2D header;
		private Texture2D background;
		private GUISkin skin;
		
		public void Start()
		{
			skin = (GUISkin)Resources.Load (Settings.GUI_SKIN_LARGE_TEXT);
			header = (Texture2D)Resources.Load("textures/gui_mainMenuHeader");
			background = (Texture2D)Resources.Load("textures/gui_menuBackground");
		}
		
		public void OnGUI()
		{	
			if (IsActive)
			{	
				GUI.skin = skin;	
				GUI.DrawTexture(new Rect(Screen.width/2 - 163, Screen.height/2 - 125, 326, 260),background);
				GUI.DrawTexture(new Rect(Screen.width/2 - 163, Screen.height/2 - 250, 326, 198),header);
							
				if (GUI.Button(new Rect(Screen.width/2 - Settings.GUI_BUTTON_WIDTH/2, Screen.height/2 - boxHeight/2 + 80, Settings.GUI_BUTTON_WIDTH, Settings.GUI_BUTTON_HEIGHT), "new game"))
				{
					Hide();
					StartGame();
				}
				else if (GUI.Button(new Rect(Screen.width/2 - Settings.GUI_BUTTON_WIDTH/2, Screen.height/2 - boxHeight/2 + 120, Settings.GUI_BUTTON_WIDTH, Settings.GUI_BUTTON_HEIGHT), "highscore"))
				{
					Hide();
					ShowScore();
				}
				else if (GUI.Button(new Rect(Screen.width/2 - Settings.GUI_BUTTON_WIDTH/2, Screen.height/2 - boxHeight/2 + 160, Settings.GUI_BUTTON_WIDTH, Settings.GUI_BUTTON_HEIGHT), "help"))
				{
					Hide();
					ShowManual();
				}								
				else if (GUI.Button(new Rect(Screen.width/2 - Settings.GUI_BUTTON_WIDTH/2, Screen.height/2 - boxHeight/2 + 200, Settings.GUI_BUTTON_WIDTH, Settings.GUI_BUTTON_HEIGHT), "credits"))
				{
					Hide();
					ShowCredits();
				}
			}
		}
		
		public event Action StartGame;
		public event Action ShowScore;
		public event Action ShowCredits;
		public event Action ShowManual;
	}
}

